import { Effect, Reducer, Subscription, history } from 'umi';

export interface RegisterModelState {
  name: string;
}

export interface RegisterModelType {
  namespace: 'register';
  state: RegisterModelState;
  effects: {
    query: Effect;
  };
  reducers: {
    save: Reducer<RegisterModelState>;
  };
  subscriptions: { setup: Subscription };
}

const RegisterModel: RegisterModelType = {
  namespace: 'register',
  state: {
    name: 'nihao',
  },
  effects: {
    *query({ payload }, { call, put }) { },
  },
  reducers: {
    save(state, action) {
      return {
        ...state,
        ...action.payload,
      };
    },
  },
  subscriptions: {
    setup({ dispatch, history }) {
      return history.listen(({ pathname }) => { });
    },
  },
};

export default RegisterModel;
